package model

import (
	"strconv"
)

type User struct {
	Userid   *int64  `json:"userid" gorm:"primaryKey;uniqueIndex;column:userid; comment:用户id"`
	Username *string `json:"username" gorm:"uniqueIndex;column:username; comment:用户名"`
	Password *string `json:"-" gorm:"column:password; comment:密码"` // json:"-"：不返回值
	Nickname *string `json:"nickname" gorm:"column:nickname; comment:昵称"`
	Email    *string `json:"email" gorm:"uniqueIndex;column:email; comment:邮箱"`
	Phone    *string `json:"phone" gorm:"uniqueIndex;column:phone; comment:手机号"`
	Address  *string `json:"address" gorm:"column:address; comment:地址"`
	Gender   *int8   `json:"gender" gorm:"column:gender; comment:性别：1-男,2-女"`
	Timestamps
}

func (u User) GetUid() string {
	return strconv.FormatInt(*u.Userid, 10)
}

func (u User) GetUname() string {
	return *u.Username
}
